<?php include _include(ADMIN_PATH.'view/htm/header.inc.htm');?>

<!--{hook admin_user_update_start.htm}-->

<div class="row">
	<div class="col-lg-8 offset-lg-2">
		<div class="btn-group m-b-1" role="group">
			<?php echo admin_tab_active($menu['article']['tab'], 'add');?>
		</div>
		<div class="card">
			<div class="card-block">
				<h4 class="card-title">编辑文章</h4>
				<form action="<?php echo $url;?>" method="post" id="form">

					<input type="text" id="title" name="title" class="form-control" value="<?php echo $article['title'];?>">
				
					<select name="cid" class="form-control" style="margin:10px 0;">
						<?php foreach($catalog as $c){ ?>
						<option value="<?php echo $c['id'];?>" <?php if($article['cid']==$c['id']){echo 'selected';}?>><?php echo $c['name'];?></option>
						<?php } ?>
					</select>

					<textarea id="editor" name="content" style="height:300px;margin-bottom:10px;"><?php echo $article['content']; ?></textarea>

					<div class="form-group row">
						<div class="col-sm-12">
							<button type="submit" class="btn btn-primary btn-block" id="submit" data-loading-text="提交中...">确认</button>
							<a role="button" class="btn btn-secondary btn-block" href="javascript:history.back();">返回</a>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<?php include _include(ADMIN_PATH.'view/htm/footer.inc.htm');?>

<script type="text/javascript" src="../view/js/editor/ueditor.config.js"></script>
<script type="text/javascript" src="../view/js/editor/ueditor.all.min.js"></script>
<script type="text/javascript" src="../view/js/editor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="../view/js/editor/chushi.js"></script>


<script>

var jform = $('#form');
var jsubmit = $('#submit');
jform.on('submit', function() {
	jform.reset();
	jsubmit.button('loading');
	var postdata = jform.serialize();
	$.xpost(jform.attr('action'), postdata, function(code, message) {
		if(code == 0) {
			$.alert(message);
			jsubmit.text(message).delay(3000).button('reset');
		} else if(code < 0) {
			$.alert(message);
			jsubmit.button('reset');
		} else {
			alert(message);
			jform.find('[name="'+code+'"]').alert(message).focus();
			jsubmit.button('reset');
		}
	});
	return false;
});

$('#nav_pc li.user, #nav_mobile li.user').tab('show');

</script>